package com.goodluck.goodluckim.sdk;

import android.content.Context;
import android.content.Intent;

import com.goodluck.goodluckim.db.DBManager;
import com.goodluck.goodluckim.network.WebSocketService;
import com.goodluck.goodluckim.sdk.service.AutoService;
import com.goodluck.goodluckim.sdk.service.ContactService;
import com.goodluck.goodluckim.sdk.service.MessageService;
import com.goodluck.goodluckim.sdk.service.SessionService;
import com.goodluck.goodluckim.sdk.service.TeamService;
import com.goodluck.goodluckim.utils.ScreenUtil;
import com.goodluck.goodluckim.widget.emoji.StickerManager;

/**
 * 初始化（配置之类的初始化也可以放进来）
 * Created by wyj on 2018/9/10.
 */

public class GLIMClient {

    /**
     * 消息
     */
    private MessageService messageService;
    private SessionService sessionService;
    private TeamService teamService;
    private ContactService contactService;
    private AutoService autoService;

    private GLIMClient() {
    }

    private static class InstanceHolder {
        static GLIMClient INSTANCE = new GLIMClient();
    }

    public static GLIMClient getInstance() {
        return GLIMClient.InstanceHolder.INSTANCE;
    }

    /**
     * sdk初始化
     *
     * @param context
     * @param token
     */
    public void init(Context context, String token) {
        StickerManager.getInstance().init();
        ScreenUtil.init(context);
        context.startService(new Intent(context, WebSocketService.class));
        DBManager.init(context);
        sessionService = new SessionService();
        messageService = new MessageService();
        teamService = new TeamService();
        contactService = new ContactService();
        autoService = new AutoService();
    }

    public MessageService getMessageService() {
        return messageService;
    }

    public SessionService getSessionService() {
        return sessionService;
    }

    public TeamService getTeamService() {
        return teamService;
    }

    public ContactService getContactService() {
        return contactService;
    }

    public AutoService getAutoService() {
        return autoService;
    }
}
